/*
* Copyright 2016 YONYOU Corporation Ltd. All Rights Reserved.
*
* This software is published under the terms of the YONYOU Software
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @Project         marketing

* @Package         com.yonyou.marketing.message.push.entrance

* @Author          LuZhen

* @FileName        MessageSender

* @Date            2016/11/15

----------------------------------------------------------------------------------
*     Date          Who             Version         Comments
* 1. 2016/11/15        LuZhen          1.0             Create Source
*
----------------------------------------------------------------------------------
*/
package com.yonyou.gmmc.service.wechatpush.mq.entrance;

import org.marketing.common.constants.MessagePushConstant;
import org.marketing.common.entity.wechatpushmessage.WeChatMessageProtocol;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class MessageSender {


    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 将消息重新放入队列中
     * @param messageProtocol 协议消息
     */
    public void send(WeChatMessageProtocol messageProtocol){
        this.rabbitTemplate.convertAndSend(MessagePushConstant.WECHAT_QUEUE, messageProtocol);
    }

    /**
     * 将消息重新放入测试队列中
     * @param message  文本消息
     */
    public void send2Test(String message){
        this.rabbitTemplate.convertAndSend(MessagePushConstant.WECHAT_QUEUE_TEST, message);
    }

}
